#{extends 'backend_main.html' /}
#{set title:'后台管理' /}
<div class="x-nav">
    <span class="layui-breadcrumb"><a>首页</a><a>内容管理</a><a><cite>内容管理</cite></a></span>
    <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="/BackendCenter/newsList" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
  <div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" id="form1" action="/BackendCenter/newsList">
        <input type="hidden" id="currPage" name="currPage"/>
        <input type="hidden" id="pageSize" name="pageSize"/>
        <div class="layui-col-md1">
            <select name="channel_id">
                <option value="">--请选择--</option>
                #{list channelList}
                    <option ${_?.id==channel_id?"selected":""} value="${_?.id}">${_?.channel_name}</option>
                #{/list}
            </select>
        </div>
        <div class="layui-col-md1">
            <input type="text" name="title"  placeholder="请输入检索信息标题" autocomplete="off" class="layui-input" value="${title}">
        </div>
        <div class="layui-col-md1">
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </div>
    </form>
  </div>
  <xblock>
    <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
    <button class="layui-btn" onclick="x_admin_show('添加文章信息','./newsEdit?v=show')"><i class="layui-icon"></i>添加</button>
    <span class="x-right" style="line-height:40px">共有数据：${pageBean?.totalCount} 条</span>
  </xblock>
  <table class="layui-table" lay-size="sm">
    <thead>
      <tr>
        <th><div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div></th>
          <th>ID</th>
          <th>所属频道</th>
        <th width="500px;">标题</th>
        <th>图片</th>
        <th>阅读次数</th>
        <th >创建日期</th>
          <th >修改日期</th>
        <th >操作</th>
        </tr>
    </thead>
    <tbody id="tableImgs">
    #{list pageBean?.page}
      <tr>
        <td>
          <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='${_?.id}'><i class="layui-icon">&#xe605;</i></div>
        </td>
          <td>${_?.id}</td>
          <td>${_?.channel_name}</td>
        <td>${_?.title}</td>
        <td><img src="/FileController/images?uuid=${_?.filename}" width="80" height="30" onclick="layerPhotos({src:this.src})"></td>
        <td>${_?.read_count}</td>
          <td>${_?.created_date}</td>
          <td>${_?.modify_date}</td>
        <td class="td-manage">
            <a title="编辑"  onclick="x_admin_show('编辑','newsEdit?id=${_?.id}&v=edit')" href="javascript:;" class="layui-btn layui-btn-xs"> 编辑</a>        </td>
      </tr>
    #{/list}
    </tbody>
  </table>
  #{page currPage:pageBean?.currPage,totalCount:pageBean?.totalCount,pageSize:pageBean?.pageSize,theme:2,style:1 /}
</div>
<script>
    /* 条件搜素查询 */
    function showPage(currPage, pageSize){
        $("#currPage").val(currPage);
        $("#pageSize").val(pageSize);
        $("#form1").submit();
    }
  layui.use(['laydate','layer'], function(){
    var laydate = layui.laydate;
    var layer = layui.layer;
    //执行一个laydate实例
    laydate.render({
      elem: '#start' //指定元素
    });
    //执行一个laydate实例
    laydate.render({
      elem: '#end' //指定元素
    });
      layer.ready(function(){ //为了layer.ext.js加载完毕再执行
          layer.photos({
              photos: '#tableImgs'
              //,shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
          });
      });
  });
  function delAll (argument) {
    var data = tableCheck.getData();
    if(data==""){
        layer.msg("请先选择要删除的条目");
        return;
    }
    layer.confirm('确认要删除吗？'+data,function(index){
        $.ajax({
            type:"POST",                      //请求类型
            url:"./newsDel",                 //URL
            data:"ids="+data,                  //传递的参数
            dataType:"json",                 //返回的数据类型
            success:function(data){          //data就是返回的json类型的数据
                console.log(data);
                window.location.reload();
            }
        });
    });
  }
</script>